package com.example.a22310.myapplication.Beans;

import android.content.Intent;
import android.databinding.BaseObservable;
import android.databinding.Bindable;
import android.databinding.BindingAdapter;
import android.view.View;
import android.widget.ImageView;

import com.example.a22310.myapplication.Activity.ClubDetail;
import com.squareup.picasso.Picasso;

import java.io.Serializable;
import java.util.List;

import static com.example.a22310.myapplication.GloableClass.Yuejian.IMG_URL;

public class Club {


    private int code;
    private List<ClublistBean> clublist;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public List<ClublistBean> getClublist() {
        return clublist;
    }

    public void setClublist(List<ClublistBean> clublist) {
        this.clublist = clublist;
    }

    public static class ClublistBean  extends BaseObservable implements Serializable {
        /**
         * id : 1
         * clubname : 海天俱乐部
         * clubaddr : 大连东软信息学院三期
         * clubpic : 8.jpg
         * clubtele : 18944445555
         * clubtime : 2017-09-12 20:30:00
         * clubbrief : 实际道路喀什的拉伸的灵魂；收到啦好啦恢复良好的萨勒夫哈试试看发快递发货咯的开发开始大幅和
         */

        private int id;
        private String clubname;
        private String clubaddr;
        private String clubpic;
        private String clubtele;
        private String clubtime;
        private String clubbrief;

        public int getNumber_of_visitors() {
            return number_of_visitors;
        }

        public void setNumber_of_visitors(int number_of_visitors) {
            this.number_of_visitors = number_of_visitors;
        }

        private int number_of_visitors;



        public ClublistBean() {
        }

        public ClublistBean(int id,  String clubname, String clubaddr, String clubpic,String clubtele,
                            String clubtime,String clubbrief,int number_of_visitors) {
            this.id = id;
            this.clubname = clubname;
            this.clubaddr=clubaddr;
            this.clubpic =clubpic;
            this.clubtele = clubtele;
            this.clubtime = clubtime;
            this.clubbrief=clubbrief;
            this.number_of_visitors=number_of_visitors;
        }

        @BindingAdapter("clubpic")
        public static void loadInternetImage(ImageView iv, String clubpic) {
            clubpic = IMG_URL+clubpic;
            Picasso.with(iv.getContext()).load(clubpic).into(iv);
        }

        @Override
        public String toString() {
            return "ClublistBean{" +
                    "id='" + id + '\'' +
                    ", clubname='" + clubname + '\'' +
                    ", clubaddr='" + clubaddr + '\'' +
                    "clubpic='" + clubpic + '\'' +
                    ", clubtele='" + clubtele + '\'' +
                    ", clubtime='" + clubtime + '\'' +
                    "clubbrief='" + clubbrief + '\'' +
                    '}';
        }

        public void onItemClick(View view){
            Intent intent=new Intent(view.getContext(),ClubDetail.class);
            //往详情传递数据
            ClublistBean  clublistBean = new ClublistBean();
            clublistBean.setId(getId());
            clublistBean.setClubname(getClubname());
            clublistBean.setClubaddr(getClubaddr());
            clublistBean.setClubpic(getClubpic());
            clublistBean.setClubtele(getClubtele());
            clublistBean.setClubtime(getClubtime());
            clublistBean.setClubbrief(getClubbrief());
            intent.putExtra("club",clublistBean);
            view.getContext().startActivity(intent);
        }

        @Bindable

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public String getClubname() {
            return clubname;
        }

        public void setClubname(String clubname) {
            this.clubname = clubname;
        }

        public String getClubaddr() {
            return clubaddr;
        }

        public void setClubaddr(String clubaddr) {
            this.clubaddr = clubaddr;
        }

        public String getClubpic() {
            return IMG_URL+clubpic;
        }

        public void setClubpic(String clubpic) {
            this.clubpic = clubpic;
        }

        public String getClubtele() {
            return clubtele;
        }

        public void setClubtele(String clubtele) {
            this.clubtele = clubtele;
        }

        public String getClubtime() {
            return clubtime;
        }

        public void setClubtime(String clubtime) {
            this.clubtime = clubtime;
        }

        public String getClubbrief() {
            return clubbrief;
        }

        public void setClubbrief(String clubbrief) {
            this.clubbrief = clubbrief;
        }
    }
}
